import java.util.Hashtable;
import java.util.StringTokenizer;
import java.util.Vector;

class P10004 {

	public static void main(String[] args) {
		String line = readLn();
		while (!"0".equals(line)) {
			process(Integer.parseInt(line));
			line = readLn();
		}
		
	}

	private static void process(int n) {
		int l = Integer.parseInt(readLn());
		Hashtable graph = new Hashtable();
		for (int k = 0; k < n; k++) {
			Nodio nodio = new Nodio(k);
			graph.put(new Integer(k), nodio);
		}
		
		for (int k = 0; k < l; k++) {
			StringTokenizer st = new StringTokenizer(readLn());
			Nodio x = (Nodio) graph.get(new Integer(st.nextToken()));
			Nodio y = (Nodio) graph.get(new Integer(st.nextToken()));
			x.addNodio(y);
			y.addNodio(x);
		}
		
		Vector toVisit = new Vector();
		Nodio x = (Nodio) graph.get(new Integer(0));
		x.visited = true;
		x.color = "red";
		
		int length = x.adj.size();
		
		for (int k = 0; k < length; k++) {
			Nodio no = (Nodio) x.adj.elementAt(k);
			no.color = "black";
			toVisit.addElement(no);
		}
		
		while (!toVisit.isEmpty()) {
			Nodio no = (Nodio) toVisit.elementAt(0);
			toVisit.removeElement(no);
			no.visited = true;
			String color = no.color;
			for (int k = 0; k < no.adj.size(); k++) {
				Nodio justFound = (Nodio)no.adj.elementAt(k);
				if (justFound.color != null) {
					if (justFound.color.equals(no.color)) {
						System.out.println("NOT BICOLORABLE.");
						return;
					}
				} else {
					justFound.color = getOtherColor(color);
					toVisit.addElement(justFound);
				}
			}
		}
		
		System.out.println("BICOLORABLE.");
		
	}

	private static String getOtherColor(String color) {
		if ("black".equals(color)) {
			return "red";
		} else {
			return "black";
		}
	}

	static String readLn() {
		String newLine = System.getProperty("line.separator");
		StringBuffer buffer = new StringBuffer();
		int car = -1;
		try {
			car = System.in.read();
			while ((car > 0) && (car != newLine.charAt(0))) {
				buffer.append((char) car);
				car = System.in.read();
			}
			if (car == newLine.charAt(0))
				System.in.skip(newLine.length() - 1);
		} catch (java.io.IOException e) {
			return (null);
		}
		if ((car < 0) && (buffer.length() == 0))
			return (null);
		return (buffer.toString()).trim();
	}

}

class Nodio {

	   int id;

	   Vector adj;

	   boolean pointed;
	   
	   boolean visited;
	   
	   String color = null;
	   
	   public Nodio(int id) {
	       this.id = id;
	       this.adj = new Vector();
	       pointed = false;
	   }

	   public void addNodio(Nodio otherNodio) {
	           adj.addElement(otherNodio);
	   }

	   public int hashCode() {
		   return id;
	   }
	   
	   public boolean equals(Object o) {
	       Nodio otherNodio = (Nodio) o;
	       return otherNodio.id == this.id;
	   }
	   
	   public String toString() {
		   return "[ID:\t" + id + ",p="+pointed+" ]";
	   }
	   
	}
